# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Maintainer: Jakub Jirutka <jakub@jirutka.cz>
pkgname=nvui
pkgver=0.2.1
pkgrel=6
pkgdesc="A modern frontend for Neovim"
url="https://github.com/rohit-px2/nvui"
arch="all !riscv64"  # blocked by neovim
license="MIT"
depends="hicolor-icon-theme neovim"
makedepends="
	boost-dev
	catch2
	cmake
	fmt-dev
	msgpack-cxx-dev
	ninja
	qt5-qtbase-dev
	qt5-qtsvg-dev
	"
source="https://github.com/rohit-px2/nvui/archive/v$pkgver/nvui-$pkgver.tar.gz
	fhs-paths.patch
	use-sane-animation-time.patch
	nvui.sh
	$pkgname.desktop
	"

prepare() {
	default_prepare

	# Remove images that are used only in Readme.
	rm -rf assets/display
}

build() {
	local crossopts=
	if [ "$CBUILD" != "$CHOST" ]; then
		crossopts="-DCMAKE_SYSTEM_NAME=Linux -DCMAKE_HOST_SYSTEM_NAME=Linux"
	fi
	cmake -G Ninja -B build \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DBUILD_SHARED_LIBS=True \
		-DCMAKE_BUILD_TYPE=None \
		$crossopts .
	cmake --build build
}

check() {
	cd build
	CTEST_OUTPUT_ON_FAILURE=TRUE LANG=C ctest
}

package() {
	install -D -m755 build/nvui -t "$pkgdir"/usr/libexec/
	install -D -m755 "$srcdir"/nvui.sh "$pkgdir"/usr/bin/nvui

	install -d "$pkgdir"/usr/share/$pkgname
	cp -r assets vim "$pkgdir"/usr/share/$pkgname/

	install -D -m644 "$srcdir"/$pkgname.desktop -t "$pkgdir"/usr/share/applications/
	install -D -m644 assets/appicon.png "$pkgdir"/usr/share/icons/hicolor/128x128/apps/$pkgname.png
}

sha512sums="
e5e1eeb7f63455bb9d5b128c10056940c903a428329ad6634f6739d707faa7b6316d2fc8e7572b2ef4ee8281c36e2bac4828e2916c13298ba1abca9bc6a59649  nvui-0.2.1.tar.gz
3f657ee1d23b0d3e9b2fe024f11527ced00359505391266510823c3b0e077e547decddc5d40b1e6eba796603062b5771a22669995ffb73091370796263006bb7  fhs-paths.patch
dd60e7c60a3269d777b9fd0dd11d89a8ebb796cb23dd403cb66a1a6b9b527d356216b060c849b1760d8aef1b575a95bf57043e9986081329baefc229366bb0c0  use-sane-animation-time.patch
d781d307ad39d53f91660455fe0c6bed4698b9c70daca178652ba72d2326005dc47cfbb039c62ef97b165ae5be96e49c2e3e837f9674689b9717a336db65f7c2  nvui.sh
03c2ea47f3b7fb748978fbe4dc54d475db2258e6078061595f0da8fa02a4eba0610138f1b2c14d8aa6a25dc7299abb687f53a44d0a1eedd3da06587107679ecf  nvui.desktop
"
